const { db, query } = require("../../db/db");
const util = require("util");
const moment = require("moment");

async function GetCircleList(req, res) {
  const CircleTypeId = req.body.CircleTypeId;

  const Select_circleList = util.format(
    "SELECT CircleId, \
    CircleTypeId,\
    IFNULL(CircleTitle, '') AS CircleTitle, \
    IFNULL(CircleUrl, '') AS CircleUrl, \
    CirclePeople, \
    PinsNum, \
    IFNULL(CreateTime, '') AS CreateTime, \
    IFNULL(CreateUser, '') AS CreateUser \
  FROM Circle \
  where CircleTypeId=%s",
    CircleTypeId
  );

  const Select_Circle_res = await query(Select_circleList);

  res.send({
    status: 0,
    CircleList: Select_Circle_res,
  });
}

module.exports = { GetCircleList };
